package 
{
  import assets.Demo;
  import flash.display.MovieClip;
  import flash.display.Sprite;
  import flash.events.Event;
  import mge.ui.controls.Button;
  import mge.ui.events.ButtonEvent;
	
	/**
	 * ...
	 * @author ivan
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
      
      var b:MovieClip = new Demo();
      b.addEventListener(ButtonEvent.CLICK, onButtonClick, true);
      addChild(b);
		}
    
    private function onButtonClick(e:ButtonEvent):void
    {
      trace("Button click " + (e.target as Button).name);
    }
		
	}
	
}